package com.tenbent.product.center.example.stu.service;

import java.util.List;
import java.util.Map;

import com.tenbent.product.base.exception.TenbentException;
import com.tenbent.product.base.query.page.PageResult;
import com.tenbent.product.base.query.page.Pageable;
import com.tenbent.product.base.service.BaseService;
import com.tenbent.product.center.example.stu.bo.Student;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;

/**
 * 服务层集成缓存
 *
 * @author Randy
 *
 *         Created by ThinkPad on 2017/7/27.
 */
public interface StudentService extends BaseService<Student> {

	List<Student> queryStuList(Student stu) throws TenbentException;

	PageResult<Student> queryStuPage(Pageable pageable) throws TenbentException;

	PageResult<Map<String, Object>> queryStuPageMap(Pageable pageable) throws TenbentException;

	@CachePut(value = "STU_CACHE", key = "'student_' + #result.id")
	Student saveStu(Student stu) throws TenbentException;

	@CachePut(value = "STU_CACHE", key = "'student_' + #result.id")
	Student updateStu(Student stu) throws TenbentException;

	@Cacheable(value = "STU_CACHE", key = "'student_' + #id", unless = "#result == null")
	Student findOne(Integer id) throws TenbentException;

	@CacheEvict(value = "STU_CACHE", key = "'student_' + #id")
	void removeStu(Integer id) throws TenbentException;
}
